package com.ruoyi.attendance.mapper;

import java.util.List;
import com.ruoyi.attendance.domain.AttendanceInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 考勤记录Mapper接口
 * 
 * @author Weiney
 * @date 2025-03-01
 */
public interface AttendanceInfoMapper 
{
    /**
     * 查询考勤记录
     * 
     * @param attendanceId 考勤记录主键
     * @return 考勤记录
     */
    public AttendanceInfo selectAttendanceInfoByAttendanceId(Long attendanceId);

    /**
     * 根据courseRecordId查询考勤记录
     * @param courseRecordId course_record的主键
     * @return
     */
    public AttendanceInfo selectAttendanceInfoByCourseRecordId(Long courseRecordId);

    /**
     * 查询考勤记录列表
     * 
     * @param attendanceInfo 考勤记录
     * @return 考勤记录集合
     */
    public List<AttendanceInfo> selectAttendanceInfoList(AttendanceInfo attendanceInfo);

    /**
     * 学生查询所有选课老师发布的考勤列表
     *
     * @param attendanceInfo 考勤记录
     * @return 考勤记录集合
     */
    public List<AttendanceInfo> selectAttendanceInfoListForStudent(AttendanceInfo attendanceInfo);

    /**
     * 新增考勤记录
     * 
     * @param attendanceInfo 考勤记录
     * @return 结果
     */
    public int insertAttendanceInfo(AttendanceInfo attendanceInfo);

    /**
     * 修改考勤记录
     * 
     * @param attendanceInfo 考勤记录
     * @return 结果
     */
    public int updateAttendanceInfo(AttendanceInfo attendanceInfo);

    /**
     * 删除考勤记录
     * 
     * @param attendanceId 考勤记录主键
     * @return 结果
     */
    public int deleteAttendanceInfoByAttendanceId(Long attendanceId);

    /**
     * 批量删除考勤记录
     * 
     * @param attendanceIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAttendanceInfoByAttendanceIds(Long[] attendanceIds);

    @Select("select course_record_id from attendance_info where attendance_id = #{attendanceId}")
    public Long selectCourseIdByAttendanceId(Long attendanceId);

    /**
     * 根据courseRecordId在sign_record表中查询签到状态
     * @param courseRecordId
     * @return
     */
    @Select("select sign_status from sign_record where user_id = #{userId} and course_record_id = #{courseRecordId}")
    Integer selectSignStatusByCourseRecordIdAndUserId(@Param("courseRecordId") Long courseRecordId, @Param("userId") Long userId);

    @Select("select end_type from attendance_info where course_record_id = #{courseRecordId}")
    Integer selectAttendanceInfoEndTypeByCourseRecordId(Long courseRecordId);
}
